/*  Novelties: A visual novel programming language based on JavaFX
    Copyright (C) 2008  Hao Xu

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * /
 /*
 * SoundPlayer.fx
 *
 * Created on Apr 7, 2008, 3:19:41 PM
 */

package avgengine;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.Manager;
/**
 * @author ertri
 */

class MusicPlayer {
    attribute player : Player;
    attribute url : String;
    
    operation load();
    operation start();
    operation stop();
}

operation MusicPlayer.load() {
   var nurl;
   if (url.contains(":") == false) {
        var f= new File(url);
        nurl = new URL("file:///{f.getAbsolutePath()}");
   } else {
        nurl = new URL(url);
   }
    
    println("{nurl}");
    player = Manager.createPlayer(nurl);
}

operation MusicPlayer.start() {
    player.start();
}

operation MusicPlayer.stop() {
    player.stop();
}